// Desktop (instantiate JTF COM Wrapper)
var desktop = new ActiveXObject("SilkTestLib.Desktop");

// Base state information
var baseStateData = {};
baseStateData.url = "www.google.at";
baseStateData.locator = "/BrowserApplication/BrowserWindow";
baseStateData.techDomains = "xBrowser";
baseStateData.exe = "C:\\Program Files\\Internet Explorer\\iexplore.exe";
//baseStateData.exe = "C:\\Program Files\\Mozilla Firefox\\firefox.exe";

// Execute Base State
function baseState() {
    return desktop.executeBrowserBaseState(baseStateData.exe, baseStateData.url, baseStateData.locator, baseStateData.techDomains);
}

function testCase0() {
    var browser = baseState();
    var elements = browser.findAll("//input");
    WScript.Echo(elements);
    WScript.Echo(elements.size);
    var i;
    for (i = 0; i < elements.size; i++)
    {
        WScript.Echo(elements.get(i).tagName);
    }
}

function testCase1() {
    var browser = baseState();
    var elements = browser.findAll("//input");
    WScript.Echo(elements);
    WScript.Echo(elements.size);
    var i;
    for (i = 0; i < elements.size; i++) {
        WScript.Echo(elements.get(i).tagName);
    }
}

function testCase2() {
    var browser = baseState();
    var element = browser.find("//body");
    var children = element.getChildren();
    WScript.Echo(children);
    WScript.Echo(children.size);
    var i;
    for (i = 0; i < children.size; i++) {
        WScript.Echo(children.get(i).tagName);
    }
}

function testCase3() {
    var browser = baseState();
    var element = browser.find("//input[@name='q']");
    var children = element.getPropertyList();
    WScript.Echo(children);
    WScript.Echo(children.size);
    var i;
    for (i = 0; i < children.size; i++) {
        WScript.Echo(children.get(i));
    }
}

function testCase4() {
    var browser = baseState();
    var element = browser.find("//input[@name='q']");
    var methods = element.getMethodList();
    WScript.Echo(methods);
    WScript.Echo(methods.size);
    var i;
    for (i = 0; i < methods.size; i++) {
        WScript.Echo(methods.get(i));
    }
}

function testCase5() {
    var browser = baseState();
    var element = browser.find(".//DomButton[@type='submit' and @name='btnG']");
    element.getProperty("tagName"); // this caused a crash
    var tagname = element.getProperty("tagName");
    WScript.Echo(tagname);
}

testCase5();